function req(obj) {
	return new Promise((resolve, reject) => {
		// const HOST = getApp().globalData.baseUrl;
		const token = uni.getStorageSync("token") || "";
		const id = uni.getStorageSync("id") || "";
		var method = obj.method || "GET";
		var url = obj.url || "";
		var data = obj.data || {};
		var success = obj.success; // 成功回调函数
		var fail = obj.fail; //表示失败后，要执行的回调函数
		if (token == null || token == "") {
			var header = obj.header || {
				"Content-Type": "application/json; charset=UTF-8"
			}
		} else {
			var header = obj.header || {
				"Content-Type": "application/json; charset=UTF-8",
				"Authorization": token,
				"id": id
			}
		}
		uni.request({
			url: url,
			data: data,
			sslVerify: false,
			method: method,
			header: header,
			success: ((res) => {
				if (res.data.state == "fail" && res.data.isTokenTimeout == 1) {
					uni.showToast({
						title: "身份信息失效，请重新登录",
						icon: "none",
						duration: 2000
					})
					setTimeout(() => {
						uni.reLaunch({
							url: "/pages/auth/login/login"
						})
					}, 2000)
				} else if (res.statusCode == "200") {
					resolve(res.data)
				}
			}),
			fail: ((err) => {
				reject(err)
			})
		})
	})
}
export default req
